package algorithm;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @ClassName Test1
 * @Author 刘正星
 * @Date 2021/6/18 下午9:20
 * @Description
 */
public class Test1 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int line = Integer.parseInt(scanner.nextLine());

//        HashMap<Integer, List<String>> map = new HashMap<>();

        List<String[]> list = new ArrayList<>();

        List<Integer> sums = new ArrayList<>();

        String [] str1 = new String[line];

        String [] str2 = new String[line];

        for (int i = 0; i < line; i++) {
            String str = scanner.nextLine();
            list.add(str.split(" "));
            str1[i] = str.split(" ")[i];
            str2[i] = str.split(" ")[line-1-i];
        }

        list.add(str1);
        list.add(str2);



        list.stream().forEach((item)->{
            System.out.println(String.join(" ",item));
          int sum =  Arrays.stream(item).mapToInt(value -> Integer.parseInt(value)).sum();
            System.out.println("和："+sum);

        });


        int max = 0;
        int index = 0;
        for(int i = 0 ;i<list.size();i++ ){
            String [] item = list.get(i);
//            System.out.println(Arrays.asList(item).toString());
           int  sum = 0;
            for (int j = 0; j < item.length; j++) {
                sum +=Integer.valueOf(item[j]);
            }
            if(sum > max){
                max = sum;
                index = i;
            }
            sums.add(sum);
        };

        IntSummaryStatistics collect = sums.stream().collect(Collectors.summarizingInt(value -> value));

        System.out.println(Arrays.toString(list.get(index)));

        System.out.println(sums.stream().mapToInt(value ->value).sum());





    }
}
